/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.icanci.coupon.mapper;

import cn.icanci.coupon.form.CouponVO;
import cn.icanci.coupon.model.Coupon;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 * @author icanci
 * @date Created in 2021/05/01 10:22
 * @version 1.0
 */
public interface CouponMapper {

    /**
     * 更新一批优惠券
     * @param couponList 优惠券列表
     * @return 返回优惠券
     */
    int insertManyRows(List<Coupon> couponList);

    /**
     * 查询优惠券的 唯一键
     * @return
     */
    List<String> searchAllByUniqueKey();

    /**
     * 根据 unique key 查询一条数据
     * @param unk
     * @return
     */
    Coupon queryOneByUnk(String unk);

    /**
     * 根据 couponNumber 一张优惠券
     * @param couponNumber 优惠券唯一编号
     * @return
     */
    Coupon findOneByCouponNumber(String couponNumber);

    /**
     * 更新状态
     * @param coupon
     * @return
     */
    int updateStatus(Coupon coupon);

    /**
     * 获取被占用的个数
     * @param unk
     * @return
     */
    int queryOccupyByUnk(String unk);
    /**
     * 获取被使用的个数
     * @param unk
     * @return
     */
    int queryUsedByUnk(String unk);

    /**
     * 根据优惠券查询所有
     * @param unk
     * @return
     */
    List<Coupon> queryAllByUnk(String unk);

    /**
     * 在线的优惠券个数
     * @param unk
     * @return
     */
    int queryOnlineByUnk(String unk);

    /**
     * @param unk
     * @param condition
     * @return
     */
    CouponVO queryOneByCondition(@Param("unk") String unk,@Param("condition") String condition);

    /**
     * 查询
     * @param unk
     * @return
     */
    Coupon searchAllCouponsLimitTime(@Param("unk")String unk, @Param("limitTime") Date limitTime);
    /**
     * 根据 唯一key查询一条
     * @param uniqueKey
     * @return
     */
    Coupon queryOneByUnkLimit(String uniqueKey);

    /**
     * 根据 唯一key查询一条
     * @param couponNumber
     * @return
     */
    Coupon queryOneByCouponNumber(String couponNumber);
}
